package com.knife.domain;
import com.knife.dbo.IObject;
import com.knife.db.ComDAL;
import com.knife.review.BlogReview;

import java.io.Serializable;
import java.sql.ResultSet;
import java.util.Vector;
public class BlogNewsDir implements IObject,Serializable {

  //EasyJWeb Tools自动代码生成
  //属性部份

  	private String cid;

  	private String title;
  	private String parentsn;
  	private String dirPath;
  	private String intro;
  	private Integer sequence;
  	private Integer types;
  	private String tagImg;
  	private String inputuser;
  	private Integer status;
  
//EasyDBO自动映射部份
	public String getTableName() {
		return "blognewsdir";
	}

	public String getKeyField() {
		return "cid";
	}

	public String getKeyGenerator() {
		return "com.knife.dbo.RandomIdGenerator";
	}

//getter及setter方法

 	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}
  	
  	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
  	public String getParentSn() {
		return parentsn;
	}

	public void setParentSn(String parentsn) {
		this.parentsn = parentsn;
	}
  	public String getDirPath() {
		return dirPath;
	}

	public void setDirPath(String dirPath) {
		this.dirPath = dirPath;
	}
  	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}
  	public Integer getSequence() {
		return sequence;
	}

	public void setSequence(Integer sequence) {
		this.sequence = sequence;
	}
  	public Integer getTypes() {
		return types;
	}

	public void setTypes(Integer types) {
		this.types = types;
	}
  	public String getTagImg() {
		return tagImg;
	}

	public void setTagImg(String tagImg) {
		this.tagImg = tagImg;
	}
  	public String getInputUser() {
		return inputuser;
	}

	public void setInputUser(String inputuser) {
		this.inputuser = inputuser;
	}
  	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Vector<BlogNewsDir> getListAll(String Env) {
		Vector<BlogNewsDir> vc = new Vector<BlogNewsDir>();
		String strSql=" select * from blognewsdir where 1=1";
		if (!Env.equals(""))
			strSql = strSql + " and " + Env;
		ComDAL theDAL = null;
		try {
			theDAL = new ComDAL();
			System.out.println(strSql);
			// if(true)return null;
			ResultSet rs = theDAL.DoSelect(strSql);
			if (rs != null) {
				do {
					BlogNewsDir blogNewsDir = new BlogNewsDir();
					
					blogNewsDir.setCid(rs.getString("cid"));
					blogNewsDir.setDirPath(rs.getString("dirPath"));
					blogNewsDir.setTitle(rs.getString("title"));
					blogNewsDir.setInputUser(rs.getString("inputuser"));
					vc.addElement(blogNewsDir);
				} while (rs.next());
				rs.close();
			}
		} catch (Exception e) {
			theDAL.close();
			e.printStackTrace();
		}
		theDAL.close();
		return (vc);
	}
	
	public int getCountOfDir(BlogNewsDir dir){
		String sqlstr="select count(0) as counts from blognewsdoc where dirSn='"+dir.getCid()+"'";
		ComDAL theDAL = null;
		int count=0;
		try{
			theDAL = new ComDAL();
			ResultSet rs=theDAL.DoSelect(sqlstr);
			if(rs!=null){
				
				count=rs.getInt("counts");
				theDAL.close();
				return count;
			}else{
				theDAL.close();
				return 0;
			}
		}catch(Exception ex){
			theDAL.close();
			return 0;
		}
		
	}
  }
